package com.aistar.config;



import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import java.text.SimpleDateFormat;

@Configuration
public class QuartzConfig {

    private  static  final String LIKE_TASK_IDENTITY_UP = "LikeTaskQuartzup";
    @Bean
    public JobDetail quartzDetail_1(){
        return JobBuilder.newJob(LikeTask.class).withIdentity(LIKE_TASK_IDENTITY_UP).storeDurably().build();
    }

    @Bean
    public Trigger quartzTrigger_1() {
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(5)  //设置时间周期单位秒
 //               .withIntervalInHours(2)  //两个小时执行一次
                .repeatForever();
        return TriggerBuilder.newTrigger().forJob(quartzDetail_1())
                .withIdentity(LIKE_TASK_IDENTITY_UP)
                .withSchedule(scheduleBuilder)//CronScheduleBuilder.cronSchedule("0 40 17 ? * *")
                .build();
    }

}
